﻿using Bridge.Shared.Models;
using Microsoft.AspNetCore.Mvc;
using SysFiles;
using SysFiles.Input;
using SysFiles.Output;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace Bridge.System.HttpApi
{
    [Route("[controller]/[action]")]
    public class SysFileController : AbpController
    {
        private ISysFileService _sysFileService;
        public SysFileController(ISysFileService sysFileService)
        {
            _sysFileService = sysFileService;
        }
        [HttpPost]
        public async Task<ResponseResult> DeleteFileByUrl(List<string> input)
        {
            try
            {
                return await _sysFileService.DeleteFileByUrl(input);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
        }
        [HttpPost]
        public async Task<ResponseResult> DownloadFile(string path, long fileId = 0)
        {
            try
            {
                return await _sysFileService.DownloadFile(path,fileId);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
        }
        [HttpPost]
        public async Task<ResponseResult> UploadFile([FromForm]UploadFileInput input)
        {
            try
            {
                return await _sysFileService.UploadFile(input);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
        }

        [HttpPost]
        public async Task<PageResponseResult<SysFileOutput>> GetSysFilesPageList(SysFilePageInput input)
        {
            try
            {
                return await _sysFileService.GetSysFilesPageList(input);
            }
            catch (Exception ex)
            {
                return PageResponseResult<SysFileOutput>.Fail(ex.Message);
            }
        }

    }
}
